﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace Apply
{
    class BookTempSelector : DataTemplateSelector
    {
        public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            if (item != null && item is Book)
            {
                var book = item as Book;
                switch (book.Title)
                {
                    case "工厂-标题1":
                        return (container as FrameworkElement).FindResource("temp1") as DataTemplate;
                    case "工厂-标题2":
                        return (container as FrameworkElement).FindResource("temp2") as DataTemplate;
                    case "工厂-标题3":
                        return (container as FrameworkElement).FindResource("temp3") as DataTemplate;
                    default:
                        return null;
                }
            }
            return null;
        }
    }
}
